/*
 * @Author: worldzb 
 * @Date: 2018-10-02 11:24:44 
 * @Last Modified by: worldzb
 * @Last Modified time: 2018-11-29 15:06:50
 */
import Handsontable from 'handsontable-pro';

class TableSettings{
    static default(){
        return {
            id:'',
            language: 'zh-CN',
            colHeaders: true,
            rowHeaders: true,
            contextMenu: true,
            autoWrapRow: true,
            mergeCells: true,
            contextMenu: true,
            manualRowResize: true,
            manualColumnResize: true,
            manualRowMove: true,
            manualColumnMove: true,
            //fixedRowsBottom: 2,
            exportFile: true,
            // multiColumnSorting: {
            //     indicator: true
            // },
            dropdownMenu: true,
            filters: true,
            //collapsibleColumns: true,
            hiddenColumns: true,
            bindRowsWithHeaders: true,
            outsideClickDeselects: false,
            selectionMode: 'multiple',
            minSpareRows: 1,
            minSpareCols: 1,
            //columnSorting: true,

            //公式不能和排序，列裁切同时使用
            formulas:{},
            comments: true,
            currentRowClassName: 'currentRow',
            currentColClassName: 'currentCol',
            copyPaste:true,
            colWidths:70,
            rowHeights:40
        }
    }

    /**
     * 生成初始表格填充数据
     * @param {Number} row  行
     * @param {Number} col  列
     * @param {Boolean} isFill  是否为空填充
     */
    static createData(row,col,isFill){
        if(isFill){
            return Handsontable.helper.createSpreadsheetData(col, row);
        }else{
            let data=[];
            for(let i=0;i<row;i++){
                let tempCol=[];
                for(let j=0;j<col;j++){
                    tempCol.push(null);
                }
                data.push(tempCol);
            }
            return data;
        }
    }
}


export default TableSettings;
